package Tools;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/** Game configuration class
 * @author Aikidos
 */
public class Configuration {

	/** Is mute? */
	static private boolean _isMute = false;
	
	/** Initialize */
	static public void init() throws IOException {
		// Check configuration file exist
		if (!new File("config.cfg").exists()) 
			createDefaultConfig();
		
		// Read configurations
		FileReader fr = new FileReader(new File("config.cfg"));	
		
		// Is mute?
		if (fr.read() != 0) _isMute = true;
		
		fr.close();
	}
	
	/** Is mute? */
	static public boolean isMute() {
		return _isMute;
	}
	
	/** Create default configuration file */
	static private void createDefaultConfig() throws IOException {
		File f = new File("config.cfg");
		FileWriter fw = new FileWriter(f);
		
		// Is mute?
		fw.write(0);
		
		fw.close();
	}
	
}
